<template>
  <el-input v-model.number="val" :disabled="disabled" type="number" size="mini" @input="onInput" />
</template>

<script>
export default {
  name: 'NumberInput',
  props: {
    value: {
      type: [String, Number],
      default: ''
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      val: this.value
    }
  },
  watch: {
    value(newVal, oldVal) {
      if (newVal !== oldVal) {
        this.val = newVal
      }
    }
  },
  methods: {
    onInput() {
      this.$emit('input', Number(this.val))
    }
  }
}
</script>
